package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.UserTemplate;

/**
 * QUserTemplate is a ORMLite query type for UserTemplate
 * @see UserTemplate
 */
public class QUserTemplate extends QEntityBase<UserTemplate> {

    public static final QUserTemplate $ = new QUserTemplate("USER_TEMPLATE");

    public final Column userId = field("userId").columnName("USER_ID").varchar(22).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndexF = index("CONSTRAINT_INDEX_F").column(userId).build();

        public final Index constraintIndexF6 = index("CONSTRAINT_INDEX_F6").column(templateId).build();

        public final Index primaryKeyF6 = index("PRIMARY_KEY_F6").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintF68 = foreignKey(userId, "AUTH_USER", "ID");

        public final ForeignKey constraintF68a = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QUserTemplate(String tableName) {
        super(UserTemplate.class, tableName);
    }

    @Override
    public UserTemplate newInstance() {
        return new UserTemplate();
    }

    @Override
    public Object getFieldValue(UserTemplate instance, String fieldName) {
        switch (fieldName) {
            case "userId":
                return instance.getUserId();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(UserTemplate instance, String fieldName, Object value) {
        switch (fieldName) {
            case "userId":
                instance.setUserId((java.lang.String) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

